feat: Add package flutter_gamepads#88
Merged
lea108 merged 66 commits intoflame-engine:mainfrom Apr 3, 2026
Merged
Conversation
…ased on gamepad input Users can move focus, activate widgets and emit dismiss intents which closes alert dialogs for example. Not all flutter widgets fully can be operated with the global intents. For example the Slider widgets uses private intents with additional support for keyboard shortcuts.
Rewritten example to be human-based. More specifically the AI had a Tab based control, but was still building the Bottom tabs on each page. The new example does trigger the issue that each page cannot have a GamepadControl as when the settings page is pushed on the stack the HomePage still remains and there would be duplicate focus change intents. I explored ways to handle that the gamepadControl of the page behind would automatically disable itself, but it was hard to find a reliable solution to that. Instead I changed so there is just one GamepadControl at the top and to be able to locally intercept the input you can use GamepadInterceptor widget.
Collaborator
Author
|
I'd love feedback on the name of especially the GamepadControl widget and also parameters in the API if something feels off. For me GamepadControl feels 70-80% right, but not quite sure what would feel 100% right. |
This comment was marked as resolved.
This comment was marked as resolved.
When mouse user is using the app, we don't want to focus a button in the dialog directly.
Also reduce the Flutter example a bit.
…ntation of the example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users can move focus, activate widgets and emit dismiss intents which closes alert dialogs for example.
Not all flutter widgets fully can be operated with the global intents. For example the Slider widgets uses private intents with additional support for keyboard shortcuts.
Background
The widget GamepadControl in this PR is based of a widget OverlayGamepadControl I wrote in a flame game. But it has been reworked to be more generic and apply not just for flame overlays but any widget trees.
In this work I now mainly focus on pure Flutter first, and then would like to look at Flame overlays to see what has to be done there in terms of focus management.I have now extended the example with a Flame game and provided documentation on how flutter_gamepads can be used for overlays in a Flame game. The coreflutter_gamepadspackage still remains independent of Flame.How to use it
Wrap your widgets with GamepadControl to allow users to navigate it using their gamepad.
Please do read the README.md for more in-depth info.
README.md
GamepadControl
GamepadInterceptor
Example
Todos
I use abs() a bit in the logic which possible could be re-written as conditional logic with a slight performance gain?Tier 1, Tier 2
Tier 1
There likely will be a tier 1 level support of certain things that just work out of the box.
Tier 2
But there will likely be things like the Slider where users of this package need to do some manual wiring up to make it work.
For this the package provides GampadInterceptor() and onBeforeIntent callback. There are examples of implementing tire 2 level support in the example app.